﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MTC.Common.DTO;
using MTC.Web.Business.DTO;

namespace MTC.Web.Business
{
    public class PayIns
    {

        public bool UpdateAPayIn(PayInScheduleEntity payInScheduleEntity)
        {
            MTC.Common.DTO.PayInSchedule schedule = new PayInSchedule();
            schedule.Platenumber = payInScheduleEntity.Platenumber;
            schedule.ShiftId = payInScheduleEntity.ShiftId;
            schedule.PayInDate = payInScheduleEntity.PayInDate;
            schedule.Cash = payInScheduleEntity.Cash;
            schedule.M7 = payInScheduleEntity.M7;
            schedule.Expenses = payInScheduleEntity.Expenses;
            schedule.EftPos = payInScheduleEntity.EftPos;
            schedule.Comment = payInScheduleEntity.Comment;
            schedule.ScheduleDriverTaxiId = payInScheduleEntity.ScheduleDriverTaxiId;
            schedule.DriverId = payInScheduleEntity.DriverId;
            schedule.TaxiId = payInScheduleEntity.TaxiId;
            schedule.PayInId = payInScheduleEntity.PayInId;
            
            schedule.CarriedFwdPayIn = payInScheduleEntity.CarriedFwdPayIn;
            schedule.Claims = payInScheduleEntity.Claims;
            schedule.PayInDue = payInScheduleEntity.PayInDue;
            schedule.OwnerCompany = payInScheduleEntity.OwnerCompany;
            schedule.OwnerFirstName = payInScheduleEntity.OwnerFirstName;
            schedule.OwnerLastName = payInScheduleEntity.OwnerLastName;

            return MTC.Business.PayIn.PayIn.UpdateAPayIn(schedule);
        }

        //public bool UpdateAPayIn(string Platenumber, int ShiftId, int TaxiId, int DriverId, DateTime PayInDate, decimal Cash, decimal M7, decimal EftPos, decimal Expenses, string Comment, int ScheduleDriverTaxiId)
        //{

        //    MTC.Common.DTO.PayInSchedule schedule = new PayInSchedule();
        //    schedule.Platenumber = Platenumber;
        //    schedule.ShiftId = ShiftId;
        //    schedule.PayInDate = PayInDate;
        //    schedule.Cash = Cash;
        //    schedule.M7 = M7;
        //    schedule.Expenses = Expenses;
        //    schedule.EftPos = EftPos;
        //    schedule.Comment = Comment;
        //    schedule.ScheduleDriverTaxiId = ScheduleDriverTaxiId;
        //    schedule.DriverId = DriverId;
        //    schedule.TaxiId = TaxiId;
        //    return MTC.Business.PayIn.PayIn.UpdateAPayIn(schedule);
        //}
        //public bool UpdateAPayIn(PayInEntity entity)
        //{
        //    MTC.Common.DTO.PayInSchedule schedule = new PayInSchedule();
            
        //    schedule.Cash = entity.Cash;
        //    schedule.Comment = entity.Comment;
        //    schedule.DriverId = entity.DriverId;
        //    schedule.EftPos = entity.EftPos;
        //    schedule.Expenses = entity.Expenses;
        //    schedule.Firstname = entity.Firstname;
        //    schedule.Lastname = entity.Lastname;
        //    schedule.M7 = entity.M7;
        //    schedule.PayInDate = entity.PayInDate;
        //    schedule.PayInId = entity.PayInId;
        //    schedule.Platenumber = entity.PlateNumber;
        //    schedule.ScheduleDate = entity.ScheduleDate;
        //    schedule.ScheduleDriverTaxiId = entity.ScheduleDriverTaxiId;
        //    schedule.ScheduleId = entity.ScheduleId;
        //    schedule.ShiftDescription = entity.ShiftDescription;
        //    schedule.ShiftId = entity.ShiftId;
        //    schedule.TaxiId = entity.TaxiId;


        //    return MTC.Business.PayIn.PayIn.UpdateAPayIn(schedule);
        //}

        public List<PayInScheduleEntity> GetASchedule(DateTime scheduleDate, int shiftId)
        {
            if (scheduleDate.ToString() == "1/01/0001 12:00:00 AM")
                return null;

            List<PayInScheduleEntity> listofSchedules = new List<PayInScheduleEntity>();

            List<MTC.Common.DTO.PayInSchedule> schedules = MTC.Business.PayIn.PayIn.GetAPayInSchedule(scheduleDate, shiftId);
            foreach (Common.DTO.PayInSchedule payIn in schedules)
            {
                PayInScheduleEntity entity = new PayInScheduleEntity();
                entity.Cash = payIn.Cash;
                entity.DriverId = payIn.DriverId;
                entity.EftPos = payIn.EftPos;
                entity.Expenses = payIn.Expenses;
                entity.Firstname = payIn.Firstname;
                entity.Lastname = payIn.Lastname;
                entity.M7 = payIn.M7;
                entity.PayInDate = payIn.PayInDate;
                entity.PayInId = payIn.PayInId;
                entity.Platenumber = payIn.Platenumber;
                entity.ScheduleDate = payIn.ScheduleDate;
                entity.ScheduleDriverTaxiId = payIn.ScheduleDriverTaxiId;
                entity.ScheduleId = payIn.ScheduleId;
                entity.ShiftId = payIn.ShiftId;
                entity.TaxiId = payIn.TaxiId;
                entity.ShiftDescription = payIn.ShiftDescription;
                entity.Comment = payIn.Comment;
                entity.DriverName = payIn.DriverName;
                entity.CarriedFwdPayIn = payIn.CarriedFwdPayIn;
                entity.Claims = payIn.Claims;
                entity.PayInDue = payIn.PayInDue;
                entity.OwnerCompany = payIn.OwnerCompany;
                entity.OwnerFirstName = payIn.OwnerFirstName;
                entity.OwnerLastName = payIn.OwnerLastName;
                entity.OwnerName = payIn.OwnerName;

                listofSchedules.Add(entity);
            }

            return listofSchedules;
        }

    }

}

